<?php

class db{

/*** Declare instance ***/
private static $instance = NULL;

/**
*
* the constructor is set to private so
* so nobody can create a new instance using new
*
*/
public function __construct() {
  /*** maybe set the db name here later ***/
}

/**
*
* Return DB instance or create intitial connection
*
* @return object (PDO)
*
* @access public
*
*/
public function getInstance() {

//B1.Ket noi den may chu MySQL
$con = mysql_connect("localhost", "root", "");
if(!$con)
{
	die("Loi ket noi toi MySQL");
}
//B2.Chon CSDL can lam viec
$kq = mysql_select_db("shoptivi");
if(!$kq)
{
	die("Khong kich hoat duoc CSDL shoptivi");
}
//B2.5. Thiet lap che do xu ly xau ky tu dang Unicode voi MySQL
	mysql_query("SET NAMES 'UTF8'");
}

/**
*
* Like the constructor, we make __clone private
* so nobody can clone the instance
*
*/
private function __clone(){
}

} /*** end of class ***/

?>
